<template>
  <div>
    <el-button type="primary" @click="dialogTableVisible = true">修改</el-button>
    <el-dialog v-el-drag-dialog title="修改" :visible.sync="dialogTableVisible" @close='close'>
      <el-form  ref="editData" label-position="left" label-width="70px" style='width: 400px; margin-left:50px;'>
        <el-form-item :label="'角色名称'" prop="name">
          <el-input placeholder="角色名称" v-model="editData.name"></el-input>
        </el-form-item>
        <el-form-item :label="'角色标签'" prop="role">
          <el-input v-model="editData.role"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm()">立即创建</el-button>
          <el-button @click="close()">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  import elDragDialog from '@/directive/el-dragDialog' // base on element-ui
  import store from '@/store'
  import { edit } from '@/api/shop_admin_auth/shopRole'

  export default {
    name: 'dragDialog-demo',
    directives: { elDragDialog },
    props: ['row_data'],
    data() {
      return {
        dialogTableVisible: false,
        editData: {
        }
      }
    },
    created: function() {
      console.log(this.row_data)
      this.editData = this.row_data
    },
    methods: {
      submitForm() {
        edit(store.getters.token, this.editData).then(res => {
          this.close()
        })
      },
      close() {
        console.log(this.$parent.data)
        this.$emit('getLists')
        this.dialogTableVisible = false
      }
    }
  }
</script>
